﻿/*-----------------------------------------------------------------------------!
! SaleType controller class                                                    !
!------------------------------------------------------------------------------!
! System   : Inventory Management System                                       !
! Client   : UK based                                                          !
! Date     : May 2011                                                          !
! Copyright: (C) KAWISOFT Inc                                                  !
! Program  : SaleTypeController.cs                                             !
! Function : controls all saleType functions                                   !
!------------------------------------------------------------------------------!
! Notes:                                                                       !
! Original author: Md. Shaiful Islam                                           !
===============================================================================*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model.Poribar.SaleTypePanjeri;
using Model.Panjeri;
using Model.Upadan;
using Model.Sadharon;
using Model.Sohaok;

namespace InventorySys.controller
{
    public class SaleTypeController
    {
        private ISaleTypeKaz saleTypeController;
        private Result result;

        public SaleTypeController()
        {
            saleTypeController = Panjeri.getSaleTypePanjeri();
        }

        #region get all SaleType list
        /// <summary>
        /// GetAllSaleType method
        /// </summary>
        /// <returns></returns>
        public Result GetAllSaleType()
        {
            return saleTypeController.getList();
        }
        #endregion

        #region get SaleType details
        /// <summary>
        /// GetSaleTypeDetails according with id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Result GetSaleTypeDetails(string id)
        {
            return saleTypeController.getById(id);
        }
        #endregion

        #region add new SaleType details

        /// <summary>
        /// addSaleTypeDetails
        /// </summary>
        /// <param name="saleType"></param>
        /// <returns></returns>
        public Result addSaleTypeDetails(SaleType saleType)
        {
            result = new Result();
            if (saleType.Name.Length == 0 || saleType.Name == null)
            {
                result = Util.setSuccessResult(false, "SaleType missing");
                return result;
            }
            return saleTypeController.add(saleType);
        }
        #endregion

        #region update SaleType details
        /// <summary>
        /// updateSaleTypeDetails
        /// </summary>
        /// <param name="saleType"></param>
        /// <returns></returns>
        public Result updateSaleTypeDetails(SaleType saleType)
        {
            // TODOS validation
            return saleTypeController.update(saleType);
        }

        #endregion

        #region delete SaleType details
        /// <summary>
        /// deleteSaleTypeDetails
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Result deleteSaleTypeDetails(string id)
        {
            return saleTypeController.delete(id);
        }

        #endregion
    }
}
